<?php
echo 'Report by products: <br>';
echo '<table><tr><td><b>Product</b></td>
        <td><b>Closed</b></td>
        <td><b>Assigned</b></td>
        <td><b>Tier3</b></td>
        <td><b>T3 %</b></td>
        <td><b>Linked</b></td>
        <td><b>KCS %</b></td>
        <td title="Surveys"><b>Surveys</b></td>
        <td title="Technical skill with Genesys software"><b>Skill</b></td>
        <td title="Keeping you advised of the ticket status"><b>Advised</b></td>
        <td title="Professionalism"><b>Professional</b></td>
        <td title="Time to receive resolution"><b>Time</b></td>
        <td title="Effectiveness of resolution"><b>Effectivness</b></td>
        <td title="Overall satisfaction"><b>Overall</b></td></tr>';
foreach ($productforperiod[$team] as $product => $value) {
    echo '<tr><td>' . $product . '</td>';
    echo '<td>' . $productforperiod[$team][$product]['closed'] . '</td>';
    echo '<td>' . $productforperiod[$team][$product]['open'] . '</td>';
    echo '<td title = "Closed with Tier3 hands off"';
    if ($productforperiod[$team][$product]['tier3per'] >= $tier3_threshold)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['tier3'] . '</td>';
    echo '<td title = "Tier3 (%)"';
    if ($productforperiod[$team][$product]['tier3per'] >= $tier3_threshold)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['tier3per'] . '</td>';
    echo '<td title = "KCS documents linked"';
    if ($productforperiod[$team][$product]['kcsper'] < $kcs_threshold)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['kcs'] . '</td>';
    echo '<td title = "KCS linked %"';
    if ($productforperiod[$team][$product]['kcsper'] < $kcs_threshold)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['kcsper'] . '</td>';
    echo '<td title = "Surveys">' . $productforperiod[$team][$product]['surveys'] . '</td>';
    echo '<td title = "Skill"';
    if ($productforperiod[$team][$product]['skill'] <= $cs_threshold and $productforperiod[$team][$product]['skill'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['skill'] . '</td>';
    echo '<td title = "Advised"';
    if ($productforperiod[$team][$product]['advised'] <= $cs_threshold and $productforperiod[$team][$product]['advised'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['advised'] . '</td>';
    echo '<td title = "Professionalism"';
    if ($productforperiod[$team][$product]['prof'] <= $cs_threshold and $productforperiod[$team][$product]['prof'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['prof'] . '</td>';
    echo '<td title = "Time"';
    if ($productforperiod[$team][$product]['time'] <= $cs_threshold and $productforperiod[$team][$product]['time'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['time'] . '</td>';
    echo '<td title = "Effectivness"';
    if ($productforperiod[$team][$product]['efect'] <= $cs_threshold and $productforperiod[$team][$product]['efect'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['efect'] . '</td>';
    echo '<td title = "Overall"';
    if ($productforperiod[$team][$product]['overall'] <= $cs_threshold and $productforperiod[$team][$product]['overall'] > 0)
        echo ' class="red"';
    echo '>' . $productforperiod[$team][$product]['overall'] . '</td>';
    echo '</tr>';
}

echo '</table><br><br>';
?>